package test.nettys.nio;

import java.nio.IntBuffer;
import java.util.Random;

/**
 * @Author wangshaopeng
 * @Date 2021/7/15
 */
public class NioTest0 {


    public static void main(String[] args) {
        IntBuffer buffer = IntBuffer.allocate(10);

        for (int i = 0; i < 9; i++) {
            buffer.put(new Random().nextInt(20));
        }

        System.out.println("before flip limit"+buffer.limit());
        buffer.flip();
        System.out.println("after flip limit"+buffer.limit());

        while (buffer.hasRemaining()) {
            int i = buffer.get();
            System.out.println(buffer.limit()+"::"+buffer.position()+"::"+buffer.capacity());
            System.out.println(i);

        }


    }
}
